﻿using System.Collections.Generic;

namespace Tatibah
{
    /// <summary>
    /// Internal Class used by Tables
    /// </summary>
    public class Row
    {
        private List<Cell> cells = new List<Cell>();

        /// <summary>
        /// Create a Row with the desired number of cells
        /// </summary>
        /// <param name="Cells"></param>
        /// <param name="Parent"></param>
        public Row(int Cells, Table Parent)
        {
            for (int cell = 0; cell < Cells; cell++)
            {
                Cell newCell = new Cell(Parent);
                cells.Add(newCell);
            }
        }

        /// <summary>
        /// Get a List of the Cells in this Row
        /// </summary>
        public List<Cell> Cells
        {
            get { return cells; }
        }

        /// <summary>
        /// Return the Cell at the desired Index
        /// </summary>
        /// <param name="CellIndex"></param>
        /// <returns></returns>
        public Cell this[int CellIndex]
        {
            get
            {
                if (CellIndex > cells.Count) return null;
                return cells[CellIndex];
            }
        }
    }
}
